/************************************
 * name: cpu_card.h
 * func: cpu card handle
 * date: 2015/06/03
 *
 ***********************************/

#ifndef __CPU_CARD_H__
#define __CPU_CARD_H__

#include "reader.h"
#include "psam_card.h"

#define LOAD_KEY_PATH                   "/xDF/x01"
#define ED                              0x01  // 电子存折
#define EP                              0x02  // 电子钱包

/* CPU卡 指令 */
#define APDU_ERASE_BINARY		        0x0E
#define APDU_VERIFY_PIN			        0x20
#define APDU_EXTERNAL_AUTHENTICATE	    0x82
#define APDU_INTERNAL_AUTHENTICATE	    0x88

#define APDU_READ_RECORD		        0xB2
#define APDU_ENVELOPE			        0xC2
#define APDU_WRITE_BINARY		        0xD0
#define APDU_WRITE_RECORD		        0xD2
#define APDU_UPDATE_BINARY	        	0xD6
#define APDU_UPDATE_RECORD		        0xDC
#define APDU_GET_CHALLENGE		        0x84
#define APDU_CHANGE_PIN			        0x5E
#define APDU_UNLOCK_PIN			        0x5E
#define APDU_UNLOCK_KEY			        0x5C
#define APDU_CREATE_FILE		        0xF2
#define APDU_GET_BALANCE		        0x5c
#define APDU_INITIALIZE_FOR_PURCHASE	0x50  // CPU 初始化消费指令
#define APDU_DEBIT_FOR_PURCHASE		    0x54  // CPU 消费取现指令
#define APDU_CREDIT_FOR_LOAD            0x52  // CPU 圈存指令
#define APDU_WRITE_KEY			        0xD4
#define APDU_INIT_FOR_DESCRYPT		    0x1A
#define APDU_DES_CRYPT			        0xFA
#define APDU_APPLICATION_UNBLOCK	    0x18

#define APDU_INIT_SAM_FOR_PURCHASE	    0x70  // 计算MAC1
#define APDU_CREDIT_SAM_FOR_PURCHASE	0x72  // 检验MAC2
#define APDU_SELECT_FILE		        0xA4  // 选择文件
#define APDU_GET_RESPONSE		        0xC0  // 取响应数据
#define APDU_READ_BINARY		        0xB0  // 读取二进制文件内容

extern s32 cpu_card_deal(void *op);
extern s32 cpu_card_load(void *op);

#endif

